<template>
  <div class="app-container">
    <el-row :gutter="20" >
      <el-col :span="5">
        <pointList v-on:handlePointClick="handlePointClick"></pointList>
      </el-col>
      <el-col :span="19">
        <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
          <el-form-item label="时间">
            <el-date-picker :editable="false" :clearable="false" style="width: 140px;"
                            v-model="dataTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择时间">
            </el-date-picker>
            <!--<el-input
              v-model="dataTime"
              placeholder="请输入时间"
              clearable
              size="small"
              style="width: 180px;margin: 0 10px;"
            />-->
          </el-form-item>
          <el-form-item>
            <el-button size="mini" @click="genHour" v-loading.fullscreen.lock="fullscreenLoading">生成小时数据</el-button>
            <el-button size="mini" @click="genDay" v-loading.fullscreen.lock="fullscreenLoading">生成日数据</el-button>
          </el-form-item>
        </el-form>

      </el-col>
    </el-row>

  </div>
</template>

<script>
  import { genHourData } from "@/api/basic/hourMain";
  import { genDayData } from "@/api/basic/dayMain";
  import pointList from "@/views/components/pointTreeList";

export default {
  name: "GenData",
  components: {
    pointList
  },
  data() {
    return {
      dataTime:'2021-01-27 17:00:00',
      pointId:undefined,
      fullscreenLoading:false,
    };
  },
  computed: {

  },
  mounted() {
    let nowDate = new Date();
    let byear = nowDate.getFullYear();
    let bmonth = nowDate.getMonth() + 1;
    if(bmonth<10){
      bmonth = '0'+bmonth;
    }
    this.dataTime = `${byear}-${bmonth}-01`;
  },
  created() {

  },
  methods: {
    handlePointClick(obj){
      this.pointId=obj.pointId;
    },
    //生成小时数据
    genHour() {
      this.fullscreenLoading = true;
      let obj = {
        pointId:this.pointId,
        dataTime:this.dataTime
      }
      genHourData(obj).then(response => {
        this.fullscreenLoading = false;
      });
    },
    //生成日时数据
    genDay() {
      this.fullscreenLoading = true;
      let obj = {
        pointId:this.pointId,
        dataTime:this.dataTime
      }
      genDayData(obj).then(response => {
        this.fullscreenLoading = false;
      });

    },
  }
};
</script>
